from django.utils.deprecation import MiddlewareMixin
from django.http import HttpResponseServerError
from django.core.mail import send_mail
from django.conf import settings
class ExceptionMiddle(MiddlewareMixin):
    def process_exception(self,request,exception):
        print(exception)
        send_mail(
            '服务器出错了，抢修',
            str(exception),
            '1633503528@qq.com',
            settings.WARNING_USERS,
        )
        return HttpResponseServerError(content='error'.encode())
